package com.qincji.bottombar;

import ohos.app.Context;
import ohos.global.configuration.DeviceCapability;

/**
 * description: vp和px单位转换  <br>
 *
 * @author qincji
 * @email xhunmon@126.com
 * @date 2021/6/15
 */
public class TabUtils {

    public static int px2vp(Context context, int size) {
        int density = context.getResourceManager().getDeviceCapability().screenDensity / DeviceCapability.SCREEN_MDPI;
        return size / density;
    }

    public static int vp2px(Context context, int size) {
        int density = context.getResourceManager().getDeviceCapability().screenDensity / DeviceCapability.SCREEN_MDPI;
        return size * density;
    }
}